<script setup>
import { ref } from 'vue'

// 响应式数据
const count = ref(0)
const message = ref('Hello Vue 3!')

// 方法
const increment = () => {
  count.value++
}

const decrement = () => {
  count.value--
}

const reset = () => {
  count.value = 0
}
</script>

<template>
  <div class="counter-demo">
    <h1>{{ message }}</h1>

    <div class="counter">
      <h2>计数器: {{ count }}</h2>

      <div class="buttons">
        <button @click="decrement" class="btn btn-decrease">-</button>
        <button @click="reset" class="btn btn-reset">重置</button>
        <button @click="increment" class="btn btn-increase">+</button>
      </div>

      <p v-if="count > 0" class="positive">当前数字是正数</p>
      <p v-else-if="count < 0" class="negative">当前数字是负数</p>
      <p v-else class="zero">当前数字是零</p>
    </div>
  </div>
</template>

<style scoped>
.counter-demo {
  text-align: center;
  padding: 40px;
  font-family: Arial, sans-serif;
  max-width: 400px;
  margin: 0 auto;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 20px;
  color: white;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

h1 {
  margin-bottom: 30px;
  font-size: 2rem;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.counter {
  background: rgba(255,255,255,0.1);
  padding: 30px;
  border-radius: 15px;
  backdrop-filter: blur(10px);
}

h2 {
  font-size: 1.8rem;
  margin-bottom: 25px;
  color: #fff;
}

.buttons {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-bottom: 20px;
}

.btn {
  padding: 12px 24px;
  font-size: 1.2rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: bold;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.btn-increase {
  background: #4CAF50;
  color: white;
}

.btn-decrease {
  background: #f44336;
  color: white;
}

.btn-reset {
  background: #ff9800;
  color: white;
}

p {
  font-size: 1.1rem;
  margin: 10px 0;
  padding: 10px;
  border-radius: 5px;
}

.positive {
  background: rgba(76, 175, 80, 0.3);
  color: #c8e6c9;
}

.negative {
  background: rgba(244, 67, 54, 0.3);
  color: #ffcdd2;
}

.zero {
  background: rgba(255, 152, 0, 0.3);
  color: #ffe0b2;
}
</style>